﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace blackhouse.BlackApart.Actions.Log {
    public class ImpActionLog : IActionLog {

        #region Fields

        private StringBuilder buildMessage = new StringBuilder();

        #endregion

        #region Properties

        public int LogId { get; set; }

        public DateTime StartDate { get; set; }

        public DateTime EndDate { get; set; }

        public ActionStatus Status { get; set; }

        public string Message {
            get { return this.buildMessage.ToString(); }
            set { this.buildMessage = new StringBuilder(value); }
        }

        public string Title { get; set; }

        #endregion

        #region Constructors

        public ImpActionLog() {
            this.Status = ActionStatus.Wait;
            this.StartDate = DateTime.Now;
            this.EndDate = DateTime.Now;
        }

        #endregion

        #region Methods

        public void Save() {
        }

        public IActionLog AssignNewLogToAction(Action action) {
            throw new NotImplementedException();
        }

        public void AppendToMessage(string message) {
            this.buildMessage.AppendFormat("+ {0:D,10}ms {1}", ( DateTime.Now - this.StartDate ).Milliseconds, message);
            this.buildMessage.AppendLine();
        }

        #endregion

    }
}
